package com.fita.wechat.service.impl;

import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.annotation.Dao;
import com.fita.entity.data.ShortUrl;
import com.fita.wechat.dao.ShortUrlDao;
import com.fita.wechat.service.ShortUrlService;

/**
 * 
 * @author dan
 *
 */
@Service("shortUrlService")
public class ShortUrlServiceImpl implements ShortUrlService{
    
    @Dao
    private ShortUrlDao shortUrlDao;

    /*
     * (non-Javadoc)
     * @see com.fita.wechat.service.ShortUrlService#getByShortUrl(java.lang.String)
     */
    public ShortUrl getByShortUrl(String shortUrl) {
        ShortUrl url = shortUrlDao.load(shortUrl);
        if(url != null && url.getShortUrl().equals(shortUrl)) {
            return url;
        }
        return null;
    }
    
    /*
     * (non-Javadoc)
     * @see com.fita.wechat.service.ShortUrlService#getByLongUrl(java.lang.String)
     */
    public ShortUrl getByLongUrl(String longUrl) {
        return shortUrlDao.loadByLongUrl(longUrl);
    }

}
